package com.eastfair.transport.controller;

import com.eastfair.core.base.R;
import com.eastfair.transport.service.TransportServiceProviderService;
import com.eastfair.venueservice.dto.ServiceProviderDTO;
import com.eastfair.venueservice.vo.ServiceProviderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * 主场服务商信息
 * </p>
 *
 * @author lyw
 * @date 2022 -07-15
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/serviceProvider")
public class TransportServiceProviderController {

    @Resource
    private TransportServiceProviderService transportServiceProviderService;

    /**
     * 查询主场服务商信息
     *
     * @param userId the user id
     * @return service provider by user id
     */
    @GetMapping("/getServiceProviderByUserId/{userId}")
    public R<ServiceProviderVO> getServiceProviderByUserId(@PathVariable Long userId) {
        ServiceProviderVO serviceProviderVO = transportServiceProviderService.getServiceProviderByUserId(userId);
        return R.success(serviceProviderVO);
    }

    /**
     * 新增主场服务商信息
     *
     * @param serviceProviderDTO the service provider dto
     * @return r
     */
    @PostMapping("/saveServiceProvider")
    public R<Boolean> saveServiceProvider(@RequestBody ServiceProviderDTO serviceProviderDTO) {
        return R.success(transportServiceProviderService.saveServiceProvider(serviceProviderDTO));

    }

    /**
     * 更新主场服务商信息
     *
     * @param serviceProviderDTO the service provider dto
     * @return r
     */
    @PostMapping("/updateServiceProvider")
    public R<Boolean> updateServiceProvider(@RequestBody ServiceProviderDTO serviceProviderDTO) {
        return R.success(transportServiceProviderService.updateServiceProvider(serviceProviderDTO));
    }


}
